/**
 * <copyright>
 * </copyright>
 *
 */
package lco.cRLanguage.impl;

import lco.cRLanguage.CRLanguagePackage;
import lco.cRLanguage.CalcCR;
import lco.cRLanguage.CalcMean;
import lco.cRLanguage.Callable;
import lco.cRLanguage.FindSimilar;
import lco.cRLanguage.HighestCR;
import lco.cRLanguage.Method;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Callable</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lco.cRLanguage.impl.CallableImpl#getCr <em>Cr</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.CallableImpl#getMean <em>Mean</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.CallableImpl#getHighest <em>Highest</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.CallableImpl#getSimilar <em>Similar</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.CallableImpl#getMethod <em>Method</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CallableImpl extends MinimalEObjectImpl.Container implements Callable
{
  /**
   * The cached value of the '{@link #getCr() <em>Cr</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCr()
   * @generated
   * @ordered
   */
  protected CalcCR cr;

  /**
   * The cached value of the '{@link #getMean() <em>Mean</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMean()
   * @generated
   * @ordered
   */
  protected CalcMean mean;

  /**
   * The cached value of the '{@link #getHighest() <em>Highest</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHighest()
   * @generated
   * @ordered
   */
  protected HighestCR highest;

  /**
   * The cached value of the '{@link #getSimilar() <em>Similar</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSimilar()
   * @generated
   * @ordered
   */
  protected FindSimilar similar;

  /**
   * The cached value of the '{@link #getMethod() <em>Method</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMethod()
   * @generated
   * @ordered
   */
  protected Method method;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CallableImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRLanguagePackage.Literals.CALLABLE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CalcCR getCr()
  {
    return cr;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCr(CalcCR newCr, NotificationChain msgs)
  {
    CalcCR oldCr = cr;
    cr = newCr;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__CR, oldCr, newCr);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCr(CalcCR newCr)
  {
    if (newCr != cr)
    {
      NotificationChain msgs = null;
      if (cr != null)
        msgs = ((InternalEObject)cr).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__CR, null, msgs);
      if (newCr != null)
        msgs = ((InternalEObject)newCr).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__CR, null, msgs);
      msgs = basicSetCr(newCr, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__CR, newCr, newCr));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CalcMean getMean()
  {
    return mean;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMean(CalcMean newMean, NotificationChain msgs)
  {
    CalcMean oldMean = mean;
    mean = newMean;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__MEAN, oldMean, newMean);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMean(CalcMean newMean)
  {
    if (newMean != mean)
    {
      NotificationChain msgs = null;
      if (mean != null)
        msgs = ((InternalEObject)mean).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__MEAN, null, msgs);
      if (newMean != null)
        msgs = ((InternalEObject)newMean).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__MEAN, null, msgs);
      msgs = basicSetMean(newMean, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__MEAN, newMean, newMean));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HighestCR getHighest()
  {
    return highest;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetHighest(HighestCR newHighest, NotificationChain msgs)
  {
    HighestCR oldHighest = highest;
    highest = newHighest;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__HIGHEST, oldHighest, newHighest);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHighest(HighestCR newHighest)
  {
    if (newHighest != highest)
    {
      NotificationChain msgs = null;
      if (highest != null)
        msgs = ((InternalEObject)highest).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__HIGHEST, null, msgs);
      if (newHighest != null)
        msgs = ((InternalEObject)newHighest).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__HIGHEST, null, msgs);
      msgs = basicSetHighest(newHighest, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__HIGHEST, newHighest, newHighest));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FindSimilar getSimilar()
  {
    return similar;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSimilar(FindSimilar newSimilar, NotificationChain msgs)
  {
    FindSimilar oldSimilar = similar;
    similar = newSimilar;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__SIMILAR, oldSimilar, newSimilar);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSimilar(FindSimilar newSimilar)
  {
    if (newSimilar != similar)
    {
      NotificationChain msgs = null;
      if (similar != null)
        msgs = ((InternalEObject)similar).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__SIMILAR, null, msgs);
      if (newSimilar != null)
        msgs = ((InternalEObject)newSimilar).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__SIMILAR, null, msgs);
      msgs = basicSetSimilar(newSimilar, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__SIMILAR, newSimilar, newSimilar));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Method getMethod()
  {
    return method;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMethod(Method newMethod, NotificationChain msgs)
  {
    Method oldMethod = method;
    method = newMethod;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__METHOD, oldMethod, newMethod);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMethod(Method newMethod)
  {
    if (newMethod != method)
    {
      NotificationChain msgs = null;
      if (method != null)
        msgs = ((InternalEObject)method).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__METHOD, null, msgs);
      if (newMethod != null)
        msgs = ((InternalEObject)newMethod).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.CALLABLE__METHOD, null, msgs);
      msgs = basicSetMethod(newMethod, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.CALLABLE__METHOD, newMethod, newMethod));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRLanguagePackage.CALLABLE__CR:
        return basicSetCr(null, msgs);
      case CRLanguagePackage.CALLABLE__MEAN:
        return basicSetMean(null, msgs);
      case CRLanguagePackage.CALLABLE__HIGHEST:
        return basicSetHighest(null, msgs);
      case CRLanguagePackage.CALLABLE__SIMILAR:
        return basicSetSimilar(null, msgs);
      case CRLanguagePackage.CALLABLE__METHOD:
        return basicSetMethod(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRLanguagePackage.CALLABLE__CR:
        return getCr();
      case CRLanguagePackage.CALLABLE__MEAN:
        return getMean();
      case CRLanguagePackage.CALLABLE__HIGHEST:
        return getHighest();
      case CRLanguagePackage.CALLABLE__SIMILAR:
        return getSimilar();
      case CRLanguagePackage.CALLABLE__METHOD:
        return getMethod();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRLanguagePackage.CALLABLE__CR:
        setCr((CalcCR)newValue);
        return;
      case CRLanguagePackage.CALLABLE__MEAN:
        setMean((CalcMean)newValue);
        return;
      case CRLanguagePackage.CALLABLE__HIGHEST:
        setHighest((HighestCR)newValue);
        return;
      case CRLanguagePackage.CALLABLE__SIMILAR:
        setSimilar((FindSimilar)newValue);
        return;
      case CRLanguagePackage.CALLABLE__METHOD:
        setMethod((Method)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.CALLABLE__CR:
        setCr((CalcCR)null);
        return;
      case CRLanguagePackage.CALLABLE__MEAN:
        setMean((CalcMean)null);
        return;
      case CRLanguagePackage.CALLABLE__HIGHEST:
        setHighest((HighestCR)null);
        return;
      case CRLanguagePackage.CALLABLE__SIMILAR:
        setSimilar((FindSimilar)null);
        return;
      case CRLanguagePackage.CALLABLE__METHOD:
        setMethod((Method)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.CALLABLE__CR:
        return cr != null;
      case CRLanguagePackage.CALLABLE__MEAN:
        return mean != null;
      case CRLanguagePackage.CALLABLE__HIGHEST:
        return highest != null;
      case CRLanguagePackage.CALLABLE__SIMILAR:
        return similar != null;
      case CRLanguagePackage.CALLABLE__METHOD:
        return method != null;
    }
    return super.eIsSet(featureID);
  }

} //CallableImpl
